//
//  CYWithdrawLimitCell.m
//  cyjf
//
//  Created by tauCross on 2017/5/18.
//  Copyright © 2017年 Auto Financing. All rights reserved.
//

#import "CYWithdrawLimitCell.h"



@implementation CYWithdrawLimitCellObject

@end



@interface CYWithdrawLimitCell ()

@property(nonatomic, strong)UILabel *limitLabel;
@property(nonatomic, strong)UIView *bottomLine;

@end


@implementation CYWithdrawLimitCell

- (instancetype)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier
{
    self = [super initWithStyle:style reuseIdentifier:reuseIdentifier];
    if(self)
    {
        self.backgroundColor = [UIColor clearColor];
        self.contentView.backgroundColor = [UIColor whiteColor];
        self.selectionStyle = UITableViewCellSelectionStyleNone;
        
        self.limitLabel = [[UILabel alloc] init];
        self.limitLabel.textColor = HEXCOLOR(@"999999");
        self.limitLabel.font = [UIFont systemFontOfSize:12];
        [self.contentView addSubview:self.limitLabel];
        
        self.bottomLine = [UIView cy_lineWithColor:HEXCOLOR(@"ECECEC")];
        [self.contentView addSubview:self.bottomLine];
    }
    return self;
}

+ (CGFloat)heightForObject:(id)object atIndexPath:(NSIndexPath *)indexPath tableView:(UITableView *)tableView
{
    return 40;
}

- (BOOL)shouldUpdateCellWithObject:(CYWithdrawLimitCellObject *)object
{
    self.limitLabel.text = [NSString stringWithFormat:@"该卡本次最多可提现%@元", object.limit.amountString ? : @"0"];
    
    [self setNeedsLayout];
    return YES;
}

- (void)layoutSubviews
{
    [super layoutSubviews];
    
    [self.limitLabel sizeToFit];
    self.limitLabel.left = 20;
    self.limitLabel.centerY = self.contentView.height / 2;
    
    self.bottomLine.width = self.contentView.width - 20;
    self.bottomLine.height = 1 / SCREEN_SCALE;
    self.bottomLine.bottom = self.contentView.height;
    self.bottomLine.left = 20;
}

@end
